package com.yun.platform.iot.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.platform.iot.dto.AutoGroupDto;
import com.yun.platform.iot.entity.AutoGroup;
import com.yun.platform.iot.mapper.AutoGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 自动化与组关系表
 service 
 *  @author: Hanson  2022-11-24
 */
@Service
public class AutoGroupService extends ServiceImpl<AutoGroupMapper, AutoGroup> {

    @Autowired
    private AutoGroupMapper autoGroupmapper;
    @Autowired
    private ProGroupDeviceService proGroupDeviceService;

    public List<AutoGroupDto> listByAutoId(Integer autoId) {
       //return this.lambdaQuery().eq(AutoGroup::getAutoId, autoId).list();
        return autoGroupmapper.findByAuthId(autoId);
    }

    /**
     * 检查分组ID是否存在绑定设备
     * @param groupid
     * @return
     */
    public boolean checkDel(Integer groupid) {
        if(this.lambdaQuery().eq(AutoGroup::getGroupId,groupid).count()>0){
            return true;
        }else{
            return false;
        }

    }
}